<link href="/res/css/common/aztHeadFootMal.css" rel="stylesheet"/>   
<script src="/res/js/common/jquery.1.9.1.min.js"></script>
<script src="/res/js/common/util.js" ></script>
<script src="/res/js/common/js.cookie.js"></script>
<link href="/res/third/layer/skin/default/layer.css" rel="stylesheet">

<div class="newHeader"> 
		<div class="top">
			<div class="w1200">
				<div>
					<a class="home" href="/">安装通首页</a>  |
					<a href="">服务热线：<span>400-848-1365</span></a>  
				</div>

				<div  class="flr">
					[#if Session.currentUser??]
						[#if Session.currentUser.company??]
                        	<a href="/user/userCenter">[@content_cut content=Session.currentUser.company.companyName! len=6 ending="..." /]</a>
						[#else]
                            <a href="/user/userCenter">${Session.currentUser.hiddenUserName}</a>
						[/#if]
                        <a href="javascript:logout();">退出</a>
					[#else]
                        <a href="/user/login">登录</a>
                        <a href="/user/register">免费注册</a>
					[/#if]
					<a href="/sysfoot/helpCenter">帮助中心</a>
					<!-- <a style="padding: 0px;" href="">手机安装通</a>  -->
				</div>
			</div>
		</div>
		<div class="headMiddle">
        	<a href="/index" class="logo"><img src="/res/images/logoAzt/logo.png" alt="网上采购平台"></a>
            <form method="get" action="/selloffer" id="searchForm" >
            <div class="search" id="headSearchTab">
					<div class="ppSelect">
						<select id="searchtype" >
							[#--<option value="">采购商</option>--]
							<option value="1" style="background-color: #fafafa;">产品</option>
                            <option value="2" style="background-color: #fafafa;" >供应商</option>
						</select>
					</div>
					<input id="keywords" type="text" name="keywords"  placeholder="请输入产品名称"/>
					<button type="submit"></button>

				<!--购物车-->
		[#if Session.currentUser??]
				<div class="godCar">
					<div class="titl">
						<img src="/res/images/common/head/godCar/godCar_03.jpg"/>
						购物车 <b id="carNum">0</b> 件<a>&gt;</a>
					</div>
					<div class="ulOuter" id="ulOuter" >

					</div> 
				</div>
		[/#if]
            </div>
            </form>
        </div>
        <div class="menuWrap">
        	<div class="menu w1200">
            	<div class="pcate">
              	  <a href="/member" class="menu-cate-title">全部分类</a>
              	  <script type="text/javascript"> 
              	 if($("body").hasClass("indexPage")){ 
              		document.write('<div class="body" id="menu-cate-all-out">');
              	  }else{
              		document.write('<div class="body" id="menu-cate-all-out" style="display:none;">');
              	  }
              	  </script> 
                  	 [@all_cat /]
                  </div> 
              </div> 
                <div class="conn" style="z-index:2;" >
					<div style="height: 300px;">
					[#if user?? ]
                  	<p class="adv">
                  		<!--广告图-->
                  		<img src="${user.logo!'/res/images/common/userLogo_01.jpg'}"/>
                  	</p> 
                  	<h4>Hi，您好</h4>
                  	<h4>${user.hiddenUserName!}</h4>
					[#else]
                    <p class="adv">
                            <!--广告图-->
                            <img style="cursor: pointer;" onclick="window.open('/user/userCenter')" src="/res/images/common/userLogo_01.jpg"/>
                    </p>
                    <h4>Hi，您好</h4>
                  	<a class="login" onclick="layer.login();" ></a>
                  	<a data="reg" href="/user/register" target="_blank" >免费注册></a>
					[/#if]
                  	<p class="enjoyment">
                  		<img src="/res/images/home/mallIndex_11.png"/>
                  		新品推荐
                  	</p>
                  	<ul>
						[#if newproduct??   ]
							[#list newproduct as product ]
                            <li>
                                <a title="${product.name!}" href="/offer/${product.id}.html" target="_blank" >${product.name!}</a>
                            </li>
							[/#list ]
						[/#if]
                  	</ul>
                  	</div>
                  	<hr/>
                  	<img alt="" src="/res/images/home/mallIndex_14.png">
                  	<h5>关注微信公众平台</h5>
                </div>
              <ul class="mainmenu">
              	 <li><a [#if link?? && link='member']class="current-page"[/#if] href="/member">商城首页</a></li>
              	 <li><a [#if link?? && link='list']class="current-page"[/#if] href="/shop/1872">自营商城</a></li>  
                 <li><a [#if link?? && link='hotpro']class="current-page"[/#if] href="/hotpro" target="_blank">天天爆品</a></li>
                 <li>
					<a [#if link?? && link='center']class="current-page"[/#if] href="/center" target="_blank">集采供应商</a>
                 </li>
                 <li><a [#if link?? && link='infoIndex']class="current-page"[/#if]  href="/content/infoIndex">行业资讯</a></li>
                 
              </ul>
            </div>
        </div>
</div>
<script src="/res/js/common/jquery.1.12.4.min.js" type="text/javascript"></script>
<script src="/res/js/common/jquery.ellipsis.js"></script>
<script src="/res/js/common/jQuery.numBox.js"></script>
<script src="/res/third/laytpl/template.js"></script>
<script src="/res/js/common/common.js"></script>
<script id="forcart" type="text/html" >
{{if total> 0 }}
    <h4>最新加入的商品</h4>
    <ul id="cartWrap">
	{{each list }}
		<li>
			<i onclick="cart.dCar(this,{{$value.skuId}})">×</i>
			<div>
				<p>
					<img src="{{$value.picPath}}"/>
				</p>
			</div>
			<div class="intro">
				<h5 style="width:190px;"><a href="/offer/{{$value.productId}}.html" target="_blank" >{{$value.productName}}</a></h5>
				<strong>{{$value.realPrice | priceFormat}}</strong>
			</div>
		</li>
	{{/each}}
    </ul>
    <div id="carbtn" style="text-align:right;"  class="fee">
        <button style="margin-left:0px;margin-right:15px;" type="button" onclick="location.href='/cart';">查看购物车</button>
    </div>
{{else}}
    	<ul id="cartWrap">
		{{include 'emptyCar'}}
		</ul>
	{{/if}}
</script>
<script id="emptyCar"  type="text/html">
    <li class="emptyCar">
            <img src="/res/images/common/head/godCar/godCar_11.jpg"/>
            购物车中还没有商品，赶紧选购吧！
    </li>
</script>

<script>
	$(function(){
		$(".newHeader .headMiddle .search .godCar ul li").mouseleave(function(){
			$(this).find(".inpText").text($(this).find(".sdddq").val());
		});
		
		$(".newHeader .headMiddle .search .godCar ul li>i").click(function(){
			$(this).parents("li").remove();
		});
		
		$(".newHeader .headMiddle .search .godCar ul li>div h5 a").ellipsis({maxWidth:200,maxLine:2});
	 
		$(".newHeader .headMiddle .search .godCar").hover(function(){
			$(this).children(".ulOuter").addClass("apear");
		},function(){
			$(this).children(".ulOuter").removeClass("apear");
		});
		$(this).children(".ulOuter").removeClass("apear")

	$(".newHeader .menu .pcate").hover(function(){ 
		if($("body").hasClass("indexPage")){
			return;
		}else{ 
			$(this).children("#menu-cate-all-out").show(); 
		} 
	},function(){
		if($("body").hasClass("indexPage")){
			return;
		}else{
			$(this).children("#menu-cate-all-out").hide(); 
		}
	});
	   // $(".sdddq").inputBox();
		$(this).children("#menu-cate-all-out").hide();



	$("#searchtype").change(function () {
        changeSearchType(this);
    })


});

function changeSearchType(obj) {
	var v = $(obj).val();
	if(v==1){
		$("#searchForm").attr("action","/selloffer");
		$("#keywords").attr("placeholder","请输入产品名称")
	}else if(v==2){
		$("#searchForm").attr("action","/provider");
		$("#keywords").attr("placeholder","请输入供应商名称")
	}
}


function logout() {
	$.post('/user/logout', function() {
		location.replace('/');
	});
}

[#if Session.currentUser??]
    var cart={
        init:function(){

            template.helper('priceFormat', function (price, format) {
                return $.my.currency(price,true);
            });

            //获取购物车列表
            $.ajax({
                url : '/listCart',
                type : 'post',
                dataType : 'json',
                success : function(res) {  
                    if(res && res.success) { 
                        var list = res.obj;
                        var products =[];
                        $.each(list, function() {
                            products = products.concat(this.productList);
                        });
                        $("#carNum").text(products.length);
                        var categoryhtml = template("forcart",{list:products,total:products.length});  
                        $("#ulOuter").html(categoryhtml);
                    }else{ 
                        var categoryhtml = template("forcart",{list:[],total:0});
                        $("#ulOuter").addClass("empty");
                        $("#ulOuter").html(categoryhtml);
					}
                }
            });
			return this;
        },
        dCar:function(obj,skuid){
            $(obj).parent().fadeOut(function(){
                $(obj).parent().remove();
                var size = $("#cartWrap").find("li").size();
                if(size==0){
                    $("#cartWrap").html($("#emptyCar").html());
					$("#carbtn").remove();
                }
                $("#carNum").text(size);
			});
            removeCart(skuid);
		}
    }.init();
[/#if]
</script>